package com.itbaiwei.unitday01;

import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private RecyclerView mRecyclerView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        System.out.println("进入界面MainActivity");
        setContentView(R.layout.activity_test_base);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        mRecyclerView =findViewById(R.id.rv_context1);
        //MyRecyceleView rv_context2 = rootView.findViewById(R.id.rv_context2);

        mRecyclerView.setLayoutManager(new GridLayoutManager(this,3));

        List<String> list=new ArrayList<>();
        list.add("https://pic.rmb.bdstatic.com/bjh/video/68e0f048a7476f8ae802099768c405cc.jpeg?x-bce-process=image/quality,q_100/resize,m_fill,w_588,h_781/format,f_webp");
        list.add("https://pic.rmb.bdstatic.com/bjh/video/d8c9db9289e21cce47db4dcb5df0439b.jpeg?x-bce-process=image/quality,q_100/resize,m_fill,w_588,h_781/format,f_webp");
        list.add("https://pic.rmb.bdstatic.com/bjh/250429/beautify/9b25bb5b730e0011449e45e3e8c3e992.jpeg?x-bce-process=image/quality,q_100/resize,m_fill,w_588,h_781/format,f_webp");
      //  list.add("https://pic.rmb.bdstatic.com/bjh/video/d84b727e6186f133ecd1cb6de39c3d1a.jpeg?x-bce-process=image/quality,q_100/resize,m_fill,w_588,h_781/format,f_webp");

        MyRecycleAdapter myRecycleAdapter = new MyRecycleAdapter(this, list);
        mRecyclerView.setAdapter(myRecycleAdapter);
        System.out.println("开始加载数据...");

    }

    private static class A extends RecyclerView.ItemDecoration{

        private final int space;


        public A(int space) {
            this.space = space;
        }


        @Override
        public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
            super.getItemOffsets(outRect, view, parent, state);

            outRect.left=space;

            outRect.right=space;

            //outRect.top=space;

          //  outRect.bottom=space;

//            if(parent.getChildPosition(view)==0||parent.getChildPosition(view)==parent.getAdapter().getItemCount()-1){
//                //第一个试图
//                outRect.left=0;
//                outRect.right=0;
//
//            }






        }
    }





}